-- @owner: opentestcase007
-- @date: 2020/10/15
-- @testpoint: openGauss保留关键字on作为触发器名,部分测试点合理报错
-- @modified: by opentestcase018 2021/06/29 添加清理环境语句
-- @modified by: opentestcase007 at 2022/09/15，报错信息发生变化，优化用例期望
-- @modified by: wang-tianjing1 at 2025/02/21,报错信息发生变化，优化用例

--step1:前置条件，创建源表; expect:成功
drop table if exists test_trigger_src_tbl;
CREATE TABLE test_trigger_src_tbl(id1 INT, id2 INT, id3 INT);

--step2:前置条件，创建触发表; expect:成功
drop table if exists test_trigger_des_tbl;
CREATE TABLE test_trigger_des_tbl(id1 INT, id2 INT, id3 INT);

--step3:前置条件，创建触发器函数; expect:成功
create or replace function tri_insert_func() returns trigger as
$$
declare
begin
   insert into test_trigger_des_tbl values(new.id1, new.id2, new.id3);
   return new;
end
$$ language plpgsql;
/

--step4:openGauss保留关键字on作为触发器名不带引号; expect:合理报错
create trigger on
before insert on test_trigger_src_tbl
for each row
execute procedure tri_insert_func();
/
		   
--step5:openGauss保留关键字on作为触发器名带双引号; expect:合理报错
create trigger "on"
before insert on test_trigger_src_tbl
for each row
execute procedure tri_insert_func();
/
		   
--step6:清理环境; expect:成功
drop trigger "on" on test_trigger_src_tbl cascade;

--step7:openGauss保留关键字on作为触发器名带单引号; expect:合理报错
create trigger 'on'
before insert on test_trigger_src_tbl
for each row
execute procedure tri_insert_func();
/
		   
--step8:openGauss保留关键字on作为触发器名带反引号; expect:合理报错
create trigger `on`
before insert on test_trigger_src_tbl
for each row
execute procedure tri_insert_func();
/

--step9:清理环境; expect:成功
drop table if exists test_trigger_src_tbl;
drop table if exists test_trigger_des_tbl;
drop function if exists tri_insert_func();